<?php echo $header; ?>
<div class="container">
	<div class="alert-wrap">
		<div class="alert-position" id="alert-token"></div>
		<div class="alert-position" id="alert-reset-password"></div>
		<div class="alert-position" id="alert-reset-repassword"></div>	
	</div>
<div class="row">
	<div class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3 col-xs-6 col-xs-offset-3 forgotten-body b-s-b">
		<form action="" id="form-resetpassword">
			<div class="form-group has-feedback input-margin">
				<span class="glyphicon glyphicon-lock form-control-feedback icon-pos-font"></span>
				<input type="password" name="password" id="reset-password" class="form-control b-s-b input-bg" placeholder="密码">
				<span class="glyphicon glyphicon-eye-open form-control-feedback icon-font eye-password-display"></span>
			</div>
			<div class="form-group has-feedback input-margin">
				<span class="glyphicon glyphicon-lock form-control-feedback icon-pos-font"></span>
				<input type="password" name="repassword" id="reset-repassword" class="form-control b-s-b input-bg" placeholder="再次输入密码">
				<span class="glyphicon glyphicon-eye-open form-control-feedback icon-font eye-password-display"></span>
			</div>
			<div class="input-margin input-margin-more">
				<a href="javascript:void(0);" class="btn btn-primary btn-padding b-s-b center-block" id="submit-resetpassword">重置密码</a>
			</div>
		</form>
	</div>
</div>
</div>
<?php echo $footerout;?>
<script>
	$(document).ready(function(){
		var password,repassword,info;
		var url = "<?php echo $loginurl; ?>";
    	var targettoken = $("#alert-token");
    	var targetpassword = $("#alert-reset-password");
		var targetrepassword = $("#alert-reset-repassword");

		var tokenerror = "<?php echo $error_token; ?>";
		if (tokenerror) {
			targettoken.html(warninghtml+tokenerror+"</div>");
		 	countDown(3,url,targetpassword);
		 	return false;
		}else{
			targettoken.html(warninghtml+"请重新设定您的密码！</div>");
			setTimeout(function(){
				targettoken.fadeOut("slow");
			},2000);
		}
		
		$("#reset-password,#reset-repassword").on("blur",function(){
			password = $("#reset-password").val();
			repassword =$("#reset-repassword").val();
			if(!password_vel(password,repassword,targetpassword,targetrepassword)){
				return false;
			}
		});
		$('#submit-resetpassword').on("click",function(){
			password = $("#reset-password").val();
			repassword =$("#reset-repassword").val();
			if(!password_vel(password,repassword,targetpassword,targetrepassword)){
				return false;
			}
			$.ajax({
				type:"POST",
				dataType:"json",
				url:"<?php echo $resetpassword; ?>",
				data:{password:password,userid:"<?php echo $userid;?>"},
				success: function (data){
					if (data === 1){
						targetpassword.html(warninghtml+"密码修改成功！</div>");
						setTimeout(function(){
							countDown(3,url,targetpassword);
						},1000);
					} else if(data === 0){
						targetpassword.html(warninghtml+"密码修改失败，请重试！</div>");
						setTimeout(function(){
							targetpassword.html("");
						},1500);
					} else {
						targetpassword.html(warninghtml+data+"</div>");
					}
				}
			});
		});
});
</script>
<?php echo $footer; ?>